<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('网关接口权限列表')" />
</head>
<body class="gray-bg">
    <div class="container-div">
		<div class="row">
            <div class="btn-group-sm" id="toolbar" role="group">
		        <a class="btn btn-success" onclick="$.operate.add(0)" shiro:hasPermission="system:menu:add">
                    <i class="fa fa-plus"></i> 新增
                </a>
                <a class="btn btn-primary" onclick="$.operate.edit()" shiro:hasPermission="system:menu:edit">
		            <i class="fa fa-edit"></i> 修改
		        </a>
                <a class="btn btn-info" id="expandAllBtn">
                    <i class="fa fa-exchange"></i> 展开/折叠
                </a>
	        </div>
       		 <div class="col-sm-12 select-table table-striped">
	            <table id="bootstrap-tree-table"></table>
	        </div>
	    </div>
	</div>
	
	<th:block th:include="include :: footer" />
	<script th:inline="javascript">
		var addFlag = [[${@permission.hasPermi('gateway:api:add')}]];
		var editFlag = [[${@permission.hasPermi('gateway:api:edit')}]];
		var removeFlag = [[${@permission.hasPermi('gateway:api:remove')}]];
		var prefix = ctx + "gateway/api";
		var datas = [[${@dict.getType('api_inteface_status')}]];
		$(function() {
		    var options = {
		        code: "apiId",
		        parentCode: "parentId",
		        uniqueId: "apiId",
		        expandAll: false,
		        expandFirst: false,
		        url: prefix + "/list",
		        createUrl: prefix + "/add/{id}",
		        updateUrl: prefix + "/edit/{id}",
		        removeUrl: prefix + "/remove/{id}",
		        modalName: "菜单",
		        columns: [{
                    field: 'selectItem', 
                    radio: true
                 },
                 {
		            title: '接口名称',
		            field: 'apiName',
		            formatter: function(value, row, index) {
		                if ($.common.isEmpty(row.icon)) {
		                    return row.apiName;
		                } else {
		                    return '<i class="' + row.icon + '"></i> <span class="nav-label">' + row.apiName + '</span>';
		                }
		            }
		        },
		        {
		            field: 'apiCode',
		            title: '接口编码',
		            align: "left"
		        },
		        {
		            field: 'status',
		            title: '状态',
		            align: "left",
		            formatter: function(value, row, index) {
		            	return $.table.selectDictLabel(datas, row.status);
		            }
		        },
		        {
		            field: 'url',
		            title: '请求地址',
		            width: '30%',
		            align: "left"
		        },
		        {
                    field : 'extend1', 
                    title : '支付编码'
                },
		        {
		            title: '操作',
		            align: "left",
		            formatter: function(value, row, index) {
		                var actions = [];
		                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.apiId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
		                actions.push('<a class="btn btn-info btn-xs ' + addFlag + '" href="javascript:void(0)" onclick="$.operate.add(\'' + row.apiId + '\')"><i class="fa fa-plus"></i>新增</a> ');
		                actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.apiId + '\')"><i class="fa fa-trash"></i>删除</a>');
		                return actions.join('');
		            }
		        }]
		    };
		    $.treeTable.init(options);
		});
	</script>
</body>
</html>